<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let dictionary = Object.create(null);
      dictionary.apple = "Apple";
      // __proto__ 普通属性
      dictionary.__proto__ = "test";

      //   dictionary.toString = function () {
      //     return Object.keys(this).join(",");
      //   };
      Object.defineProperty(dictionary, "toString", {
        value: function () {
          // Object.keys() 自动屏蔽不可遍历属性和隐藏属性
          return Object.keys(this).join(",");
        },
        enumerable: false,
      });

      for (let key in dictionary) {
        console.log(key); // __proto__,apple
      }

      console.log(dictionary.toString()); // __proto__,apple
    </script>
  </body>
</html>
